<%@page import="com.yh.news.biz.*,com.yh.news.entity.*,java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新闻列表</title>
<link rel="stylesheet" 
	href="css/bootstrap.min.css">  
<!-- 	<script src="js/jquery-3.1.1.js"></script> -->
	<script 
	src="js/bootstrap.min.js"></script>
</head>
<body>
<%/*
	Object obj=session.getAttribute("news");
	List<News> list=null;
	Page p;
	if(obj==null){
		response.sendRedirect("donews.jsp?opt=find");//交给处理页
		return;
	}else{
	    p=(Page)obj;
		list=p.getPageList();//转型,把page对象转型为list
		session.removeAttribute("news");
	}
	*/
%>
	<c:if test="${empty page }">
	<jsp:forward page="donews.jsp?opt=find"></jsp:forward>
	</c:if>
	
	<table class="table table-bordered">
		<caption>新闻列表</caption>
		<thead>
			<tr>
				<th>标题</th>
				<th>作者</th>
				<th>创建时间</th>
				<th>操作 </th>
			</tr>
		</thead>
		<tbody>
			
			<c:forEach items="${page.pageList }" var="n">
			<tr>
				<td>${n.ntitle }</td>
				<td>${n.nauthor }</td>
				<td>${n.ncreatedate}</td>
				<td>
				<a href="news_read.jsp?id=${n.nid }">详情</a>&nbsp;&nbsp;
				<a href="news_update.jsp?id=${n.nid }">修改</a>&nbsp;&nbsp;
				<a href="javascript:void()0" onclick="del(${n.nid })">删除</a>
				</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	<a href="news_add.jsp">添加</a>
	<div style="float:right;">
	
	
		[${page.pageIndex}/${page.pageTotal}]
	
	<c:if test="${page.pageIndex > 1 }">
		<a href="donews.jsp?opt=find&i=1">首页</a>
		<a href="donews.jsp?opt=find&i=${page.pageIndex-1 }">上一页</a>
	
	</c:if>
	<c:if test="${page.pageIndex < page.pageTotal }">
		<a href="donews.jsp?opt=find&i=${page.pageIndex+1 }">下一页</a>
		<a href="donews.jsp?opt=find&i=${page.pageTotal }">末尾</a>
	</c:if>
	
	</div>

</body>
</html>
	<script>
		function del(id){
			var f=confirm("确定要删除吗？");
			if(f){
				location.href="donews.jsp?opt=del&id="+id;
			}
		}
	
	</script>